package com.android.base.util;

/**
 * FileName: ActivityClickUtil
 * Author: admin
 * Date: 2021/8/12 11:04
 * Description:
 */
public class ActivityClickUtil {
    private static volatile ActivityClickUtil instance = null;
    private long lastClickTime;

    public static ActivityClickUtil getInstance() {
        if (instance == null) {
            synchronized (ActivityClickUtil.class) {
                if (instance == null) {
                    instance = new ActivityClickUtil();
                }
            }
        }
        return instance;
    }

    public boolean isFastClick() {
        return isFastClick(1000);
    }

    public boolean isFastClick(long interval) {
        long time = System.currentTimeMillis();
        if (time - lastClickTime > interval) {
            lastClickTime = time;
            return false;
        }
        return true;
    }

    public void clear() {
        lastClickTime = 0;
    }
}